<?php
/*
 * RestController is a specific type of Controller that allows you to implement
 * behaviors for HTTP METHODS
 * 
 *
 * @author dan
 */
abstract class RestController extends Controller {
    abstract function get();
    abstract function post();
    abstract function put();
    abstract function delete();
    
    final public function index(){
        
        $method = $_SERVER['REQUEST_METHOD'];
        
        switch($method){
            
            case 'POST':
                $this->post();
                break;
            case 'PUT':
                $this->put();
                break;
            case 'DELETE':
                $this->delete();
                break;
            case 'GET':
                 $this->get();
                 break;
            default:
                throw new HttpCodeException(HttpCodeException::UNSUPPORTED_METHOD);
                break;
        }
        
    }
    
    
}